package cn.newgrand.common;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.text.StyleConstants;

import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;

/**
 * @author SidneyRen E-mail:SidneyRen@hotmail.com
 * @version create time：2010-10-21 下午02:59:47
 * 类说明
 */
public class DateUtil {
	
	/**
     * Returns the formatted date.
     *
     * @param insertDate the date to format.
     * @return the formatted date.
     */
    private String toMessageTime(Date insertDate) {
        final LocalPreferences pref = SettingsManager.getLocalPreferences();

        if (insertDate == null) {
            insertDate = new Date();
        }

//        StyleConstants.setFontFamily(styles, defaultFont.getFontName());
//        StyleConstants.setFontSize(styles, defaultFont.getSize());

        if (pref.isTimeDisplayedInChat()) {
      	  
            final SimpleDateFormat formatter = new SimpleDateFormat(pref.getTimeFormat());
            final String date = formatter.format(insertDate);

            return "(" + date + ") ";
        }
        return "";
    }
	
}
